import { defineConfig } from 'vitepress'

export default defineConfig({
    base: process.env.IS_VERCEL ? '/' : '/doc/', // 根据部署位置配置，如在 https://a.com/doc/ 应该配置 /doc/
    title: 'MiniBlink 简易指南',
    description: 'MiniBlink',
    themeConfig: {
        nav: nav(),

        sidebar: {
            '/guide/': sidebarGuide(),
            '/api/': sidebarAPI()
        },
    }
});

function nav() {
    return [
        { text: '指南', link: '/guide/getting-started', activeMatch: '/guide/' },
        { text: 'API', link: '/api/all', activeMatch: '/api/' },
        {
            text: '官方链接',
            items: [
                {
                    text: '官网',
                    link: 'https://miniblink.net/mb/'
                },
                {
                    text: 'MB 源代码',
                    link: 'https://gitee.com/weolar_admin/miniblink57'
                }
            ]
        },
        { text: '文档仓库', link: 'https://gitee.com/cybran/miniblink-doc' },
    ]
}

function sidebarGuide() {
    return [
        {
            text: '基础',
            collapsed: false,
            items: [
                { text: '快速开始', link: '/guide/getting-started' },
                { text: '获取网页内容', link: '/guide/get-web-content' },
                { text: '网络操作相关', link: '/guide/network-operation-related' },
                { text: '页面操作相关', link: '/guide/page-operation-related' },
                { text: '问题简易排查法', link: '/guide/troubleshooting' },
                { text: '生命周期回调索引', link: '/guide/life-cycle-functions' },
                { text: '功能设置相关函数索引', link: '/guide/config-functions' },
                { text: '命令和事件索引', link: '/guide/commands-and-events-index' },
            ]
        },
        {
            text: '深入',
            collapsed: false,
            items: [
                { text: 'Javascript 和 C++ 绑定如何实现', link: '/guide/how-js-binding-work' },
                { text: '网络操作相关如何实现(WIP)', link: '/guide/how-net-operation-work' },
            ]
        }
    ]
}

function sidebarAPI() {
    return [
        {
            text: 'API',
            collapsed: false,
            items: [
                { text: 'API', link: '/api/all' }
            ]
        }
    ]
}